#include <iostream>
#include <unordered_set>
#include <math.h>
#define ll long long

using namespace std;

bool flag = true;

int t;

ll res[1000][101];

bool backtrack(ll diff,ll now,ll ans[],ll count,unordered_set<ll> visit,int index,ll target){
	
	if(!flag) return false;
	
	diff = min(diff,(ll)sqrt(target)); 
	
	if(diff == 0 && count <= 100 && flag){
		res[index][100] = count;
		for(int i = 0;i < count; i++){
			res[index][i] = ans[i];
		}
		flag = false;
		return false;
	}
	
	for(int i = 1;i <= diff; i++){
		if(now % i == 0 && !visit.count(i)){
			visit.insert(i);
			ans[count] = i;
			backtrack(diff - i,now + i,ans,count+1,visit,index,target);
			visit.erase(i);
			ans[count] = 0;
		}
	}
	
	return true;
	
}

int main(){
	
	int t;
	cin >> t;
	ll a[t];
	for(int i = 0; i < t; i++){
		cin >> a[i];
		ll l = 1, r = 1e6+1;
		while(l <= r){
			ll mid = l + (r-l)/2;
			if(mid * mid < a[i]){
				l = mid + 1;
			}else{
				r = mid - 1;
			}
		}
		unordered_set<ll> visit;
		ll ans[100] = {0};
		ll count = 0;
		if(l * l == a[i]){
			res[i][100] = 0;
		}else{
			bool h = true;
			while(h){
				ll diff = l * l - a[i];
				h = backtrack(diff,a[i],ans,count,visit,i,l*l);
				l++;
			}
			
			
		}
	}
	
	for(int i = 0; i < t; ++i){
		int c = res[i][100];
		if(c != 0){
			cout << c << endl;
			for(int j = 0 ; j < c; ++j){
				cout << res[i][j];
				if(j != c-1) cout << ' ';
			}
		}else{
			cout << 0;
		}
		if(i != t-1) cout << endl;
		
	}
	
	return 0;
}
